import { defineConfig } from 'vite'
import { resolve } from 'path'
import preact from '@preact/preset-vite'
function pathResolve(dir: string) {
  return resolve(__dirname, dir)
}
// https://vitejs.dev/config/
export default defineConfig({
  css: {
    preprocessorOptions: {
      scss: {
        javascriptEnabled: true, // 支持内联 JavaScript
        modifyVars: { // 更改主题
        }
      }
    }
  },
  server: {
    // Listening on all local IPs
    host: true,
    port: Number(3000),
    strictPort: true,
  },
  resolve: {
    alias: [
      // @/xxxx => src/xxxx
      {
        find: /^@\//,
        replacement: pathResolve('src') + '/',
      },
      // @/types/xxxx => src/@types/xxxx
      {
        find: /^@\/types\//,
        replacement: pathResolve('src/@types') + '/',
      },
      {
        // ~@/styles/xxxx => src/styles/xxxx
        find: /^~@\/styles\//,
        replacement: pathResolve('src/styles') + '/',
      }
    ],
  },
  plugins: [preact()],
})
